package com.cuitrip.business.share.model;

import com.cuitrip.apiservice.BusinessHelper;
import com.cuitrip.business.webview.H5UrlMaker;
import com.lab.utils.SimpleCryptoUtils;

import java.io.Serializable;

/**
 * Created by ak on 15/11/12.
 */
public class ServiceShareObject implements Serializable{

    private String sid;

    private String name;

    private String pic;

    private String shortDescription;
    private String longDescription;
    private String description;

    private String url;

    private String imagePath;

    public ServiceShareObject(String sid, String name, String pic, String description, String shortDescription, String longDescription, String url, String imagePath) {
        this.sid = sid;
        this.name = name;
        this.pic = pic;
        this.description = description;
        this.shortDescription = shortDescription;
        this.longDescription = longDescription;
        this.url = url;
        this.imagePath = imagePath;
    }


    public static ServiceShareObject getInstance(String sid, String name, String pic, String desc, String imagePath) {
        String shortDescription = desc;
        String longDescription = desc;
        if (desc.length() > 30) {
            shortDescription = desc.substring(0, 28) + "...";
        }
        if (desc.length() > 200) {
            longDescription = desc.substring(0, 200) + "...";
        }
        String hostUrl = "";
        if (BusinessHelper.BASE_ONLINE_URL.equals(BusinessHelper.API_URL)){
            hostUrl = H5UrlMaker.H5_ONLINE_URL;
        }else {
            hostUrl = BusinessHelper.API_URL;
        }

        String shareUrl = hostUrl +"/service/" + SimpleCryptoUtils.encrypt(Integer.parseInt(sid));
        return new ServiceShareObject(sid, name, pic, desc, shortDescription, longDescription, shareUrl, imagePath);
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getShortDescription() {
        return shortDescription;
    }

    public void setShortDescription(String shortDescription) {
        this.shortDescription = shortDescription;
    }

    public String getLongDescription() {
        return longDescription;
    }

    public void setLongDescription(String longDescription) {
        this.longDescription = longDescription;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }
}
